﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Repository.Models.Slideshow
{
    /// <summary>
    /// 轮播图管理
    /// </summary>
    public class SlideshowManage : BusinessFullEntityBase<Guid>
    {
        /// <summary>
        /// 标题
        /// </summary>
        public string? Title { get; set; } = "";

        /// <summary>
        /// 来源 1-内部，2-外部
        /// </summary>
        public int Source { get; set; } = 1;

        /// <summary>
        /// 来源1-内部(文章-1或课程-2类别)
        /// </summary>
        public int? SourceType { get; set; } = null;

        /// <summary>
        ///2-外部(http地址)
        /// </summary>
        public string? HttpURL { get; set; } = "";

        /// <summary>
        /// 1-内部（文章Id或课程Id）
        /// </summary>
        public Guid? ObjectId { get; set; } = null;

        /// <summary>
        /// 排序
        /// </summary>
        public int SortValue { get; set; }

        /// <summary>
        /// 是否可见
        /// </summary>
        public bool IsShow { get; set; } = true;

        /// <summary>
        /// 显示区域1-家长，2-园务
        /// </summary>
        [MaxLength(50)]
        public string? ShowRange { get; set; } = "";

        /// <summary>
        /// 链接内容
        /// </summary>
        public string? ContentTitle { get; set; } = "";

        /// <summary>
        /// 图片信息
        /// </summary>
        public SlideshowManageImage Image = new SlideshowManageImage();


        public override void ConfigureEntity(ModelBuilder builder)
        {
            builder.Entity<SlideshowManage>().ToTable("Slideshow");
            builder.Entity<SlideshowManage>(entity =>
            {
                entity.HasOne(c => c.Image).WithOne().HasForeignKey<SlideshowManageImage>(c => c.SlideshowId);
            });
        }
    }
}
